//
//  UIViewController+HHScrollPageController.m
//  Flower
//
//  Created by 花花 on 2016/12/5.
//  Copyright © 2016年 花花. All rights reserved.
//

#import "UIViewController+HHScrollPageController.h"
#import "HHScrollPageViewDelegate.h"
#import <objc/runtime.h>
char HHIndexKey;
@implementation UIViewController (HHScrollPageController)

-(UIViewController *)hh_scrollViewController{

    UIViewController *VC = self;
    while (VC) {
        if ([VC conformsToProtocol:@protocol(HHScrollPageViewDelegate)]) {
            break;
        }
        VC =VC.parentViewController;
    }
    
    return VC;
    
    
}

-(void)setHh_currentIndex:(NSInteger)hh_currentIndex{
    
    objc_setAssociatedObject(self, &HHIndexKey, [NSNumber numberWithInteger:hh_currentIndex], OBJC_ASSOCIATION_ASSIGN);
    
}
-(NSInteger)hh_currentIndex{

    return [objc_getAssociatedObject(self, &HHIndexKey)integerValue];
    

}
@end
